package cn.iocoder.yudao.module.trade.enums.order;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 交易订单 - 发货状态
 *
 * @author cai
 */
@RequiredArgsConstructor
@Getter
public enum TradeOrderDeliveryStatusEnum implements IntArrayValuable {

    UN_DELIVERED(0, "待发货"),
    DELIVER_SUCCESS(1, "已发货"),
    DELIVER_FAILED(2, "发货失败");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderDeliveryStatusEnum::getStatus).toArray();

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;

    public static boolean hasDelivered(Integer status) {
        return ObjectUtil.equals(DELIVER_SUCCESS.getStatus(), status);
    }

    public static boolean deliverFailed(Integer status) {
        return ObjectUtil.equals(DELIVER_FAILED.getStatus(), status);
    }

    @Override
    public int[] array() {
        return ARRAYS;
    }

}
